package com.sheep.Pattern.Factory.customer;

import com.sheep.Pattern.Factory.factorys.factory.EmailFactory;
import com.sheep.Pattern.Factory.factorys.MessageFactory;
import com.sheep.Pattern.Factory.factorys.factory.PhoneFactory;

/**
 * 客户端
 */
public class Custom {
    /*
     *  工厂接口
     */
    private final MessageFactory messageFactory;

    /*
     *  构造器注入
     */
    public Custom(MessageFactory messageFactory) {
        this.messageFactory = messageFactory;
    }

    /*
     *  发送消息
     */
    public void send() {
        messageFactory.createMessage().send();
    }


}

class Test {
    public static void main(String[] args) {
        EmailFactory emailFactory = new EmailFactory();
        PhoneFactory phoneFactory = new PhoneFactory();

        Custom emailCustom = new Custom(emailFactory);
        Custom phoneCustom = new Custom(phoneFactory);


        emailCustom.send();
        phoneCustom.send();
    }
}